package com.mz.ozy.mvp.presenter;


import android.app.Activity;

import com.mz.ozy.base.BasePresenterImpl;
import com.mz.ozy.bean.RechargeRecordBean;
import com.mz.ozy.mvp.model.RechargeRecordModel;
import com.mz.ozy.mvp.view.RechargeRecordContract;
import com.mz.ozy.net.MyObserver;
import com.mz.ozy.utils.RxUtil;

import org.json.JSONObject;

import okhttp3.ResponseBody;

/**
 * Created by administrator on 2018/12/3.
 */
public class RechargeRecordPresenter extends BasePresenterImpl<RechargeRecordContract.View> implements RechargeRecordContract.Presenter {

    private RechargeRecordModel mModel;

    public RechargeRecordPresenter() {
        mModel = new RechargeRecordModel();
    }


    @Override
    public void getRechargeRecord(Activity activity, String coinCode, String pageNo) {
        mModel.getRechargeRecord(activity, coinCode, pageNo)
                .compose(RxUtil.rxSchedulerHelper(mView.<ResponseBody>bindToLifecycle()))
                .subscribe(new MyObserver<RechargeRecordBean>(mView, false) {
                    @Override
                    public void onSuccesss(RechargeRecordBean bean) {
                        mView.getRechargeRecordSuccess(bean);
                    }
                });
    }

    @Override
    public void getRecharg(Activity activity, String type, String amt) {
        mModel.getRecharge(activity, type, amt)
                .compose(RxUtil.rxSchedulerHelper(mView.<ResponseBody>bindToLifecycle()))
                .subscribe(new MyObserver<JSONObject>(mView, false) {
                    @Override
                    public void onSuccesss(JSONObject bean) {
                        mView.getRechargeSuccess(bean);
                    }
                });
    }
}
